<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="../vue.global.js"></script>
</head>
<body>
<div id="app"></div>
<script>
    const app = Vue.createApp({
        data() {
            return {
                message: "<strong>hello world</strong>",
                disabled: true,
                show: false,
                name: 'title',
                count: 2,
                price: 8
            }
        },
        methods: {
            handleClick(){
                alert("123456")
            }
        },
        computed:{
            total(){
                return this.count * this.price;
            }
        },
        watch:{
            price(newValue,oldPrice){
                console.log(newValue,oldPrice)
                setTimeout(()=>{
                    console.log("price changed!")
                },3000)
            }
        },
        // 插值表达式防止转义v-html
        template: `
          <div>{{total}}</div>
        `
    });
    const vm = app.mount("#app");
    /**
     * 简写：
     * 计算属性带有缓存属性，能用计算属性就用
     * 监听器：
     * computed和watcher都能实现的功能，建议使用computed因为更加简洁
     */
</script>
</body>
</html>